package cn.xt.service.com;

import cn.xt.bean.*;
import cn.xt.dao.com.ComDao;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ComServiceImpl implements ComService {
    @Autowired
    public ComDao comDao;
    //增加评论
    @Override
    public int addcom(Com com) {
       try {
           return comDao.addcom(com);
       }catch (Exception e){
           e.printStackTrace();
       }
        return 0;
    }
    //查看评论
    @Override
    public List<Com> comlist(Integer id) {
        return comDao.comlist(id);
    }
    //查看有图评论
    @Override
    public List<Com> sjhousecom(Integer userid) {
        return comDao.sjhousecom(userid);
    }
    //房东回复房客
    @Override
    public int addhfcom(Hfcom hfcom) {
        try{
            return comDao.addhfcom(hfcom);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }
    //房东读取信息
    @Override
    public int updRead(Integer com_id) {
       try{
           return comDao.updRead(com_id);
       }catch (Exception e){
           e.printStackTrace();
       }
        return 0;
    }
    //房屋图片
    @Override
    public Fimg fimg(Integer house_id) {
        return comDao.fimg(house_id);
    }
    //消息提示
    @Override
    public int redcom(Integer house_id) {
        return comDao.redcom(house_id);
    }
    //收藏
    @Override
    public int updSc(Integer users_id) {
        return comDao.updSc(users_id);
    }
    //添加收藏
    @Override
    public int addcollocation(Collectionhouse collection){
        try{
            return comDao.addcollocation(collection);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }
    //查看收藏
    @Override
    public Collectionhouse collection(Integer users_id,Integer house_id) {
        return comDao.collection(users_id,house_id);
    }
    //取消收藏
    @Override
    public int updcoll1(Integer users_id, Integer house_id) {
       try{
           comDao.updcoll1(users_id,house_id);
       }catch (Exception e){
           e.printStackTrace();
       }
        return 0;
    }
    //取消收藏
    @Override
    public int updcoll2(Integer users_id, Integer house_id) {
        try{
            comDao.updcoll2(users_id,house_id);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }
    //查询我收藏的房屋
    @Override
    public List<Collectionhouse> mycolllist(Integer users_id, Integer collection) {
        return comDao.mycolllist(users_id,collection);
    }
    //取消收藏
    @Override
    public int updcoll(Integer collection_id, Integer users_id) {
        try{
            comDao.updcoll(collection_id,users_id);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }
    //获得房屋用户和当前用户
    @Override
    public int countusers(Integer users_id, Integer house_id) {
        return comDao.countusers(users_id,house_id);
    }

    //判断用户id和房屋id是否停驶存在
    @Override
    public int countadd(Integer users_id, Integer house_id) {
        return comDao.countadd(users_id,house_id);
    }
}
